package Exer;

import org.junit.Test;

import java.util.HashSet;

public class InterviewTest {
    @Test
    public void testStudent() {
        HashSet<Student> hashSet = new HashSet<>();
        Student s1 = new Student("Tom", 12);
        Student s2 = new Student("Jerry", 11);
        hashSet.add(s1);
        hashSet.add(s2);

        s1.setAge(13);
        hashSet.remove(s1);
        System.out.println(hashSet);// [Student(name=Jerry, age=11), Student(name=Tom, age=13)]
        hashSet.add(s1); // 再次添加,添加成功
        System.out.println(hashSet);
        // [Student(name=Jerry, age=11), Student(name=Tom, age=13), Student(name=Tom, age=13)]
        hashSet.add(new Student("Tom", 12)); // 添加成功
        System.out.println(hashSet);
    }
}
